Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set guild_ids for all commands in a cog #1202

Merged
merged 4 commits into from
Apr 8, 2022

Conversation

Middledot
Copy link
Member

Summary

class SomeCog(commands.Cog, guild_ids=[...]):
    def __init__(self, client):
        self.client = client

    @discord.slash_command(name="locale")
    async def n(self, ctx):
        await ctx.respond(ctx.interaction.locale)

    @discord.slash_command(name="guild-locale")
    async def h(self, ctx):
        await ctx.respond(ctx.interaction.guild_locale)

Would be a convenient alternative to putting guild_ids in each command or using command_attrs

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

@Middledot Middledot added status: awaiting review Awaiting review from a maintainer feature Implements a feature Merge with squash labels Mar 27, 2022
Dorukyum
Dorukyum previously approved these changes Mar 27, 2022
Copy link
Member

@Dorukyum Dorukyum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Copy link

@ooliver1 ooliver1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note not just for you, but all py-cord managers)
please test prs - this pr does not use the dunder __cog_guild_ids__ which you would notice if you did test this

discord/cog.py Outdated Show resolved Hide resolved
discord/cog.py Show resolved Hide resolved
@Lulalaby Lulalaby merged commit 798ad5e into Pycord-Development:master Apr 8, 2022
@Middledot Middledot deleted the cog-guild-ids branch April 9, 2022 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature status: awaiting review Awaiting review from a maintainer
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants